package com.hc.demo;

import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 六月Bing
 */
@Api(tags = "用户信息管理", value = "用户接口")
@RestController
@RequestMapping("/dept")
public class DeptController {
    @ApiResponse(message = "测试", code = 200)
    @ApiOperation(value = "fun", notes = "测试方法fun", httpMethod = "GET")
    @GetMapping("/fun")
    public String fun() {
        return "fun";
    }

    @PutMapping(value = "/v1/{dname}")
    @ApiOperation(value = "修改部门信息", notes = "", httpMethod = "PUT")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "token", required = true, dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "deptno", value = "部门ID", required = true, dataType = "Integer", dataTypeClass = Integer.class),
            @ApiImplicitParam(paramType = "path", name = "dname", value = "部门名称", required = true, dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "body", name = "dept", value = "用户实体", required = true, dataType = "Dept", dataTypeClass = Dept.class)
    })
    public String fun(@RequestParam(name = "deptno", value = "deptno", required = false) Integer deptno,
                      @PathVariable(value = "dname", required = true) String dname,
                      @RequestBody(required = true) Dept dept,
                      HttpServletRequest request) {
        String token = request.getHeader("token");
        return token + " " + deptno + " " + dname + " " + dept;
    }
}